package com.outdoor.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.outdoor.model.entity.Application;
import com.outdoor.model.enums.ApplicationStatus;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 申请数据访问接口
 * 
 * @author OutdoorTeam
 * @date 2025-05-18
 */
@Mapper
public interface ApplicationMapper extends BaseMapper<Application> {

    /**
     * 查询用户待处理的申请
     * 
     * @param userId 用户ID
     * @return 待处理申请列表
     */
    @Select("SELECT * FROM application WHERE user_id = #{userId} AND status = 'PENDING' ORDER BY apply_time DESC")
    List<Application> selectPendingByUser(@Param("userId") Long userId);
    
    /**
     * 分页查询用户待处理的申请
     * 
     * @param page 分页对象
     * @param userId 用户ID
     * @return 待处理申请分页列表
     */
    @Select("SELECT * FROM application WHERE user_id = #{userId} AND status = 'PENDING' ORDER BY apply_time DESC")
    IPage<Application> selectPendingByUserPage(Page<Application> page, @Param("userId") Long userId);
} 